/**
* @file io_configure.c
* @brief this is a brief description
* @details this is the detail description.
* @author fulong 
* @data 2014/12/31
* @version 1.0
* @par Copyright (c):
* @par First build
*     version: fulong 
*     data: 2014/12/31
*/
#include "io_configure.h"
#ifdef __STM32
    #include "../bsp/arch/stm32/stm32f1xx/STM32F10x_StdPeriph_Driver/inc/stm32f10x_gpio.h"
    #include "../bsp/arch/stm32/stm32f1xx/STM32F10x_StdPeriph_Driver/inc/stm32f10x_rcc.h"
void set_output(uint8 port,uint8 mode, uint8 pin)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin = (1 << pin);
    GPIO_InitStructure.GPIO_Mode = (GPIOMode_TypeDef)mode;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    switch (port)
    {
        case PORTA :
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
            GPIO_Init(GPIOA, &GPIO_InitStructure);
            break;
        case PORTB :
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB, ENABLE);
            GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
            GPIO_Init(GPIOB, &GPIO_InitStructure);
            break;
        case PORTC :
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
            GPIO_Init(GPIOC, &GPIO_InitStructure);
            break;
        default:
            break;
    }
}
void set_input(uint8 port,uint8 mode,uint8 pin)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin = 1 << pin;
    GPIO_InitStructure.GPIO_Mode = (GPIOMode_TypeDef)mode;
    switch (port)
    {
        case PORTA :
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
            GPIO_Init(GPIOA, &GPIO_InitStructure);
            break;
        case PORTC :
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
            GPIO_Init(GPIOC, &GPIO_InitStructure);
            break;
        case PORTB :
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
            GPIO_Init(GPIOB, &GPIO_InitStructure);
            break;
        default:
            break;
    }
}
#endif
